package glemipsc.implementations.glemips32;

public class Register implements glemipsc.implementations.Argument {
	private int n;
	private boolean busy;
	private int emulValue = 0;
	private static int id = 0;
	
	public Register(int n) {
		//this.n = n;
		this.n = id++;
	}
	
	public String getOpCode() {
		String code = Integer.toBinaryString(n);
		if (code.length() > 5)
			code = code.substring(code.length()-5);
		if (code.length() < 5)
			while (code.length() < 5) code = "0" + code;
		return code;
	}
	
	public void setBusy(boolean busy) {
		this.busy = busy;
	}
	public boolean isBusy() {
		return busy;
	}
	
	public String toString() {
		return "R" + n;
	}
	
	public int getEmulValue() {
		System.out.println("got " + this + " = " + emulValue);
		return emulValue;
	}
	
	public void setEmulValue(int val) {
		this.emulValue = val;
		System.out.println("set " + this + " = " + emulValue);
	}
}
